#include<iostream>
using namespace std;

// #define DEBUG_MOD
#ifdef DEBUG_MOD
#endif // DEBUG_MOD

#define MAX_LEN 16
class circularQueue
{
    private:
    char* begin = new char[MAX_LEN]{0};
    char* end = &(this->begin[MAX_LEN-1]);
    char* index = begin;
    
    void _moveP2next(char** p)
    {
        if(*p != this->end){
            *p += 1;
        }else{ // 队列塞满了，index重新回到头部
            *p = this->begin;
        }
    }

    public:
    void insert(char* input)
    {
        for(char* letter = input; *letter != 0; letter++)
        {
            if(*letter == '\\') // 清空队列
            {
                for(int i = 0; i < MAX_LEN; i++)
                {
                    this->begin[i] = 0;
                }
                this->index = this->begin;
            }
            else // 塞入队列
            {
                *(this->index) = *letter;
                this->_moveP2next(&(this->index));
            }
        }
    }

    void getStr(char** str)
    {
        *str = new char[MAX_LEN+1]{0};
        if(*(this->index) == 0) // 塞入队列的内容没有超出队列长度
        {
#ifdef DEBUG_MOD
            cout << __LINE__ << ": ";
#endif // DEBUG_MOD
            char* pStr = *str;
            char* pQueue = this->begin;
            for(; pQueue != this->index; )
            {
                *pStr = *pQueue;
#ifdef DEBUG_MOD
                cout << *pStr;
#endif // DEBUG_MOD
                pStr++;
                pQueue++;
            }
#ifdef DEBUG_MOD
            cout << endl;
#endif // DEBUG_MOD
            return;
        }
        else
        {
#ifdef DEBUG_MOD
            cout << __LINE__ << ": ";
#endif // DEBUG_MOD
            char* pStr = *str;
            char* pQueue = this->index;
            for( ; ; )
            {
                *pStr = *pQueue;
#ifdef DEBUG_MOD
                cout << *pQueue;
#endif // DEBUG_MOD
                pStr++;
                this->_moveP2next(&pQueue);
                if(pQueue == this->index) break; // p回到了index的位置
            }
#ifdef DEBUG_MOD
            cout << endl;
#endif // DEBUG_MOD
            return;
        }
    }

    void printInfo()
    {
        if(*(this->index) == 0) // 塞入队列的内容没有超出队列长度
        {
            cout << __LINE__ << ": ";
            for(char* p = this->begin; p != this->index; p++)
            {
                cout << *p;
            }
            cout << endl;
            return;
        }
        else
        {
            cout << __LINE__ << ": ";
            for(char *p = this->index; ; )
            {
                cout << *p;
                this->_moveP2next(&p);
                if(p == this->index) break; // p回到了index的位置
            }
            cout << endl;
            return;
        }
    }
};

struct Node
{
    static Node* head;

    char* str = nullptr;
    uint16_t line = 0;
    uint16_t counst = 0;
    Node* last = nullptr;
    Node* next = nullptr;

    Node(circularQueue* queue, uint16_t line)
    {
        queue->getStr(&(this->str));
        this->line = line;
        this->counst++;
    }

    bool operator==(const Node& rightNode)
    {
        int i = 0;
        for(; (this->str[i] != 0) && (rightNode.str[i] != 0); i++) // 遍历每一个char
        {
            if(this->str[i] != rightNode.str[i]) return false;  // 遇到不同的，则两个字符不相等，false
        }// 其中一个或两个遍历到了末尾还没遇到不同，则退出循环

        // 如果不是两个字符串同时走到了末尾，则两个字符不相等，false
        if((this->str[i] != 0) || (rightNode.str[i] != 0)) return false;
        return true;// 否则两个字符相同，true
    }

    void addNew(Node* newNode, bool isLarge = true)
    {
        if(this->line == newNode->line)
        {
            if(this == newNode) this->counst++; // 行号与文件名都相等的为同一个记录
        }
        else if(newNode->line > this->line) // 两个记录不相等,且新记录行号更大
        {
            if(isLarge == true) // 上一次比较也是newNode比较大，则往后走
            {
                if(this->next == nullptr)
                {
                    this->next = newNode;
                    this->next->last = this;
                }
                else
                {
                    this->next->addNew(newNode,true);
                }      
            }
            else // if(isLarge == false) 上一次比较是newNode比较小，说明之前在往前走，现在遇到newNode比较大的情况，则停止移动节点同时newNode插入this->next
            {
                // if(this->next == nullptr) 能走到这里，说明节点是刚从this->next往前走到this上的，所以this->next绝对不为nullptr
                Node* tempNext = this->next;

                this->next = newNode;
                tempNext->last = newNode;

                this->next->next = tempNext;
                tempNext->last->last = this;
            }
        }
        else // if(newNode->line < this->line) 两个记录不相等,而新记录行号较小
        {
            if(isLarge == false) // 上一次比较也是newNode比较小，则往前面走
            {
                if(this->last == nullptr)
                {
                    this->last = newNode;
                    this->last->next = this;
                }
                else
                {
                    this->last->addNew(newNode, false);
                }
            }
            else // if(isLarge == true) 上一次比较是newNode更大，则停止移动节点，同时newNode插入
            {
                // if(this->last == nullptr) 能走到这里，说明节点是刚从this->last往后走到this上的，所以this->last绝对不为nullptr
                Node* tempLast = this->last;

                this->next = newNode;
                tempLast->last = newNode;

                this->next->next = tempLast;
                tempLast->last->last = this;
            }
        }
    }

    void output()
    {
        for(char* p = this->str; *p != 0; p++)
        {
            cout << *p;
        }
        cout << ' ' << this->line << ' ' << this->counst << endl;

        if(this->next == nullptr)
        {
            return;
        }else{
            this->next->output();
        }
    }
};

Node* Node::head = nullptr;

int main()
{
    char inputPath[101] = {0};
    while(cin >> inputPath)
    {
        circularQueue queue;
        queue.insert(inputPath);

        uint16_t line;
        cin >> line;
#ifdef DEBUG_MOD
        queue.printInfo();
        cout << __LINE__ << ": " << line << endl;
#endif // DEBUG_MOD

        Node* newNode = new Node(&queue, line);
        if(Node::head != nullptr)
        {
            Node::head->addNew(newNode);
        }else{
            Node::head = newNode;
        }
    }

    Node::head->output();
    
    return 0;
}